
#ifndef PULSE_H_H
#define	PULSE_H_H

#include <stdint.h>

#ifdef	__cplusplus
extern "C" {
#endif

  typedef struct {

    uint8_t bPulse_1s;
    uint8_t bPulse_500ms;
    uint8_t bPulse_250ms;
    uint8_t bPulse_100ms;
    uint8_t bPulse_125ms;
    uint8_t bPulse_200ms;

    uint8_t bPulse_50ms;
    uint8_t bPulse_25ms;
    uint8_t bPulse_20ms;
    uint8_t bPulse_10ms;

    uint16_t PulseTimeCnt_1s;
    uint16_t PulseTimeCnt_500ms;
    uint16_t PulseTimeCnt_250ms;
    uint16_t PulseTimeCnt_100ms;
    uint16_t PulseTimeCnt_125ms;
    uint16_t PulseTimeCnt_200ms;

    uint16_t PulseTimeCnt_50ms;
    uint16_t PulseTimeCnt_25ms;
    uint16_t PulseTimeCnt_20ms;
    uint16_t PulseTimeCnt_10ms;

    uint16_t AutoCnt; //base in 10ms
    uint16_t uTickLast;

    uint8_t bWave_1s;
    uint8_t bWave_500ms;
    uint8_t bWave_250ms;
    uint8_t bWave_100ms;
  } timer_pulse_type;


  void    pulse_init(timer_pulse_type *pulse, uint16_t tickStart);
  void    pulse_create(timer_pulse_type *pulse, uint16_t uTick);


  typedef struct
  {
    uint8_t  b_pulse_100ms, b_pulse_200ms, b_pulse_500ms, b_pulse_1s;
    uint8_t  b_pulse_10ms, b_pulse_20ms, b_pulse_25ms, b_pulse_50ms;
    uint8_t  b_pulse_125ms, b_pulse_250ms;
    uint8_t  b_wave_100ms, b_wave_200ms, b_wave_500ms, b_wave_1s, b_wave_250ms;

    uint8_t  pulse_tick_old;
    uint8_t  pulse_100ms_cnt;  //base on 1ms
    uint8_t  pulse_200ms_cnt;  //base on 100ms
    uint8_t  pulse_500ms_cnt;  //base on 100ms
    uint8_t  pulse_1s_cnt;     //base on 100ms
    uint8_t  pulse_10ms_cnt;   //base on 1ms
    uint8_t  pulse_20ms_cnt;   //base on 1ms
    uint8_t  pulse_25ms_cnt;   //base on 1ms
    uint8_t  pulse_50ms_cnt;   //base on 1ms
    uint8_t  pulse_125ms_cnt;   //base on 25ms
    uint8_t  pulse_250ms_cnt;   //base on 25ms

    uint32_t auto_cnt;         //base on 100ms

  } sc_pulse_type;

  extern sc_pulse_type  sc_pulse;

  void sc_pulse_creat(uint8_t uTick);

#ifdef	__cplusplus
}
#endif

#endif	/* LEDCTR_H */
